-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async_hooks: fix default nextTick triggerAsyncId #14026
async_hooks: fix default nextTick triggerAsyncId #14026
Conversation
In the case where triggerAsyncId is null it should default to the current executionAsyncId. This worked but as a side-effect the resource object was changed too. This fix also makes the null check more strict. EmitInitS is not a documented API, thus there is no reason to be flexible in its input.
I think we should implement this for now. But long term I'm wondering if we should eliminate the polymorphism in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
Left just some silly nits (ooof I hate to be the nit guy)
@@ -147,7 +152,7 @@ class ActivityCollector { | |||
// events this makes sense for a few tests in which we enable some hooks | |||
// later | |||
if (this._allowNoInit) { | |||
const stub = { uid, type: 'Unknown' }; | |||
const stub = { uid, type: 'Unknown', handleIsObject: true }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe just isObject
? (here and everywhere, obviusly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would much rather be explicit, so many things could be an object.
@@ -147,7 +152,7 @@ class ActivityCollector { | |||
// events this makes sense for a few tests in which we enable some hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: If you're already here, could you turn this comment to a proper paragraph (capitalization, some punctuation, etc)
lib/internal/process/next_tick.js
Outdated
@@ -315,13 +315,13 @@ function setupNextTick() { | |||
} | |||
|
|||
const asyncId = ++async_uid_fields[kAsyncUidCntr]; | |||
if (triggerAsyncId === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since it's argument overload handling, could you move it up, probably just after the if (process._exiting) return
test/async-hooks/init-hooks.js
Outdated
uid, | ||
type, | ||
triggerAsyncId, | ||
// in some cases (Timeout) the handle is a function, thus the usual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: (I don't really mind but) start the sentence with a capital I
. Also (e.g. `Timeout`)
@@ -0,0 +1,37 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: style as in https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure (and but the //Flags
on the first line 🤷♂️
CI: https://ci.nodejs.org/job/node-test-pull-request/8948/ |
landed in 0fd4c73 |
In the case where triggerAsyncId is null it should default to the current executionAsyncId. This worked but as a side-effect the resource object was changed too. This fix also makes the null check more strict. EmitInitS is not a documented API, thus there is no reason to be flexible in its input. Ref: #13548 (comment) PR-URL: #14026 Reviewed-By: Refael Ackermann <refack@gmail.com>
In the case where triggerAsyncId is null it should default to the current executionAsyncId. This worked but as a side-effect the resource object was changed too. This fix also makes the null check more strict. EmitInitS is not a documented API, thus there is no reason to be flexible in its input. Ref: #13548 (comment) PR-URL: #14026 Reviewed-By: Refael Ackermann <refack@gmail.com>
In the case where triggerAsyncId is null it should default to the current executionAsyncId. This worked but as a side-effect the resource object was changed too. This fix also makes the null check more strict. EmitInitS is not a documented API, thus there is no reason to be flexible in its input. Ref: #13548 (comment) PR-URL: #14026 Reviewed-By: Refael Ackermann <refack@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
async_hooks
In the case where
triggerAsyncId
isnull
it should default to thecurrent executionAsyncId. This worked but as a side-effect the resource
object was changed too.
This fix also makes the null check more strict. EmitInitS is not a
documented API, thus there is no reason to be flexible in its input.
/cc @nodejs/async_hooks